<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 作业
        const arr = [
            { uname: '孙六', age: 39 },
            { uname: '刘七', age: 9 },
            { uname: '张三', age: 59 },
            { uname: '李四', age: 29 },
            { uname: '王二', age: 19 },
            { uname: '王二', age: 18 },
            { uname: '王二', age: 16 },
        ]
        // 前提克隆一份数据
        const newArr = JSON.parse(JSON.stringify(arr))
        // 1，把age中个位数为9的替换成*  { uname: '孙六', age: 3* },
        const newarr = newArr.map(item => {
            if (item.age % 10 === 9) {
                if (item.age > 10) {
                    const a = Math.floor(item.age / 10);
                    item.age = a + '*'
                }
                if (item.age < 10) {
                    item.age = '*'
                }
            }
            return item
        })
        console.log(newarr);
        // 2，把张三的这个对象干掉，添加个{ uname: '老六', age: 12 }
        arr.splice(2, 1, { uname: '老六', age: 12 })
        console.log(arr);
        // 3, 根据年龄排序 过滤到小于18岁的
        const newArr1 = arr.filter(item => item.age > 18)
        console.log(newArr1);
    </script>
</body>

</html>